package wordprocessing.filters;

import framework.filters.AbstractActiveFilter;
import framework.pipes.PullPipe;
import framework.pipes.PushPipe;

/**
 * Filter to output data to the target (has to be implemented)
 * 
 * @author Wetzel & Rusch
 * 
 */
public class SinkFilter extends AbstractActiveFilter<String, String> {
	public SinkFilter(PullPipe<String> pullPipe, PushPipe<String> pushPipe) {
		super(pullPipe, pushPipe);
	}

	String m_data;
	PullPipe<String> m_inputPipe;

	@Override
	public void startThread() {
		Runnable activeFilter = this;
		new Thread(activeFilter).start();
	}

	@Override
	public void doIt() {
		// because I am the sink, I am going to write the data wherever you
		// want. Just implement me

	}

	@Override
	public void run() {
		m_data = pull();
		while (m_data != null) {
			push(m_data);
			m_data = pull();
		}

	}

}
